package com.gqb;

import java.lang.reflect.Method;

public class InvokeTester {
	public int add(int param1,int param2){
		return param1+param2;
	}
	
	public String ecoh(String message){
		return "hello "+message;
	}
	public static void main(String[] args) throws Exception {
		InvokeTester tester=new InvokeTester();
		System.out.println(tester.add(1, 2));
		System.out.println(tester.ecoh("gqb"));
		System.out.println("----------------------------");
		
		Class<?> classType=InvokeTester.class;
		Object invokeTesterObject=classType.newInstance();
		System.out.println(invokeTesterObject instanceof InvokeTester);
		
		Method  addMethod=classType.getMethod("add", new Class[]{int.class,int.class});
		Object result= addMethod.invoke(invokeTesterObject, new Object[]{1,2});
		System.out.println(result);
		
		Method ecohMethod=classType.getMethod("ecoh", new Class[]{String.class} );
		Object echoresult=ecohMethod.invoke(invokeTesterObject, new Object[]{"gqb"});
		System.out.println(echoresult);
	}
}
